package com.hcrazy.manchester.app.services;

import com.hcrazy.manchester.app.jdbc.LiveCommonDAO;
import com.hcrazy.manchester.app.pojo.ErrorMsg;
import com.hcrazy.manchester.app.pojo.LiveCommon;
import com.hcrazy.manchester.app.pojo.PageModel;
import com.hcrazy.manchester.app.utils.Constant;

public class LiveCommonService {

	private LiveCommonDAO liveCommonDAO;
	
	public LiveCommonDAO getLiveCommonDAO() {
		return liveCommonDAO;
	}

	public void setLiveCommonDAO(LiveCommonDAO liveCommonDAO) {
		this.liveCommonDAO = liveCommonDAO;
	}

	public ErrorMsg addOrUpdateLiveCommon(LiveCommon common) throws Exception{
		ErrorMsg msg = new ErrorMsg();
		msg.setCode(Constant.SUCCESS);//success
		if(common.getInfoId()>0){
			liveCommonDAO.updateLiveCommon(common);
		}else{
			liveCommonDAO.addLiveCommon(common);
		}
		
		return msg;
	}
	
	public PageModel getCommonInfos(PageModel model,String search,int sortId) throws Exception{
		return liveCommonDAO.getPagedInfos(model, search, sortId);
	}
	
	public LiveCommon getInfoById(int infoId) throws Exception{
		return liveCommonDAO.getById(infoId);
	}
	
	public void delLiveCommon(int infoId) throws Exception{
		liveCommonDAO.delLiveCommon(infoId);
	}
}
